/*-------------------------------------------------------------------------------------------------------------------------------------------
Program: change_amt_bel_interaction.do
----------------------------------------------------------------------------------------------------------------------------------------*/
*version Stata/SE 17.0

clear all
set more off
macro drop _all

cd "/Volumes/GoogleDrive/My Drive/Documents/JMP/Work/Tables/tables_replication" 

use "merged_v0.31_replication.dta" , clear

encode session_id, gen(sess_id)
xtset sess_id
gen inc = hh_inc/1000

label var change_amt_sent "$\Delta$ Amount sent"
label var change_belief_sent "$\Delta$ Belief: Majority's Sending"
label var rule60 "Rule 60"
label var rule100 "Rule 100"
label var HC 	"High Caste"
label var inc "Income (rupees in '000's)"


gen info40 = (norm==40)
gen info60 = (norm==60)
/**** SPECIFICATION *****/
/****GLS with session level random effects for amt_sent1, belief_oth1
and min_acc1 *****/

gen Info60Rule100 = (info60==1 & rule100==1)
gen Info60Rule60 = (info60==1 & rule60==1)
gen Info60Norule = (info60==1 & rule==0)
gen Info40Rule60 = info40*rule60
gen Info40Rule100 = info40*rule100
gen Info40Norule = (info40==1 & rule==0)

drop if female==. | work==. | age==. | educ==. | inc==. | christian==.

drop if norm == .a

foreach yvar in change_amt_sent change_belief_sent {

xtreg 			`yvar'  Info60Rule60 Info60Rule100 Info40Norule Info40Rule60 Info40Rule100 , re   vce(cluster sess_id)
estadd local SessionFE "No"
est store 		a1_`yvar'


xtreg 			`yvar' 	 Info60Rule60 Info60Rule100 Info40Norule Info40Rule60 Info40Rule100 female  work age educ inc christian  , re  vce(cluster sess_id)
estadd local SessionFE "No"
est store 		a1_`yvar'_c

xtreg 			`yvar' 	 Info60Rule60 Info60Rule100 Info40Norule Info40Rule60 Info40Rule100  female  work age educ inc christian i.sess_id, re  vce(cluster sess_id)
estadd local SessionFE "Yes"
est store 		a1_`yvar'_c_fe
											} 
							
							
							
	
esttab  a1_change_amt_sent 		a1_change_amt_sent_c  a1_change_amt_sent_c_fe ///
		a1_change_belief_sent 	a1_change_belief_sent_c  a1_change_belief_sent_c_fe  ///
		using "Table6_BehBelChange_v2/behbelchange_interaction.tex" ,  ///
		nonumbers  star(* 0.10 ** 0.05  *** 0.01) se(1) b(1) label ///
		title("Effect of information and rule treatment conditions on change in (1) amount shared and" ///
"(2) belief about sharing by the majority of others between Round 2 and Round 1") replace 	///
		keep(Info60Rule60 Info60Rule100 Info40Norule Info40Rule60 Info40Rule100  female  work age educ inc christian) scalars("SessionFE") nonote ///
		tex addnotes("(1) GLS specification with session level random effects." ///
		             "(2) Standard errors in parentheses are clustered at the session level." ///
					 "(3) \sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)" ///
					 "(4)  Info60Norule is the reference category for the other information and rule treatments." ///
					 "(5) Employed is 1 if a participant reports having a paid job, and is 0 otherwise." ///
					 "(6) Income is measured as the monthly household income." ///
					 "(7) The reference group for Christians is Hindus and Muslims.")


eststo clear	
exit
